import { formDate, setSStore, Trim } from "@/utils/util"
import Load from '@/components/Load.vue'
export default {
	data() {
		return {
			loading: false,
			data: [],
			query: {
				"pageNum": 1,
				"pageSize": 5,
				"orderId": null,
				"customerName": null,
				"startData": "",
				"endData": "",
				"status": ""
			},
			status: [
				{ name: '全部', key: null },
				{ name: '新单', key: "N" },
				{ name: '已确认', key: "A" },
				{ name: '已入住', key: "F" },
				{ name: '已结帐', key: "C" },
				{ name: '删除另换酒店', key: "Z" },
				{ name: '删除', key: "D" },
				{ name: 'NO SHOW', key: "B" },
				{ name: '满房', key: "O" },
				{ name: '变价', key: "G" },
				{ name: '特殊满房', key: "U" },
				{ name: '变更', key: "H" },
				{ name: '有预定未查到', key: "B1" },
				{ name: '待查', key: "B2" },
				{ name: '暂不确定', key: "B3" },
				{ name: '特殊', key: "S" },
			],
			active: null,
			total: null,
		}
	},
	computed: {

	},
	watch: {

	},
	methods: {
		search() {
			this.query.status = null;
			this.active = null;
			this.getData();
		},
		getData() {

			this.query.startData = formDate(this.query.startData);
			this.query.endData = formDate(this.query.endData);
			this.query.customerName = Trim(this.query.customerName);
			this.query.orderId = Trim(this.query.orderId);
			this.loading = true;
			this.$http.post('/hotel/orderList', this.query)
				.then((res) => {
					this.loading = false;
					let status = res.data.status;
					if(status == 1001) {
						this.data = res.data.data.list;
						this.total = res.data.data.total;
						if(this.total == 0) {
							this.$message('搜索结果为空');
							return;
						}
						return;
					}
					this.$notify.error({
						title: '请求失败',
						message: '请检查网络连接或者更换搜索条件',
						duration: 3000
					});
				})
		},
		//选择不同状态的订单数据
		chooseStatus(status) {
			
			this.active = status;
			this.query.status = status;
			this.getData();
		},
		//分页
		pageChange(val) {
			this.query.pageNum = val;
			this.getData();
		},
		detail(order) {
			window.open("#/orderManage/hotel/detail?OrderId=" + order.supplierOrderId)
		},
		pay(){
			alert("待定")
		},
		cancel(){
			alert("待定")
		}
	},
	components: {
		Load,
	},
	created() {
		this.getData();
	}
}